
	<div class="block">

<div id= 'content'>
	<h2>产品管理</h2>
	
	
	
	<?php
	//print_r($_GET);
	if(isset($_GET['stat'])){
		if($_GET['stat']=='inserted'){
			
		
	
	?>
	<div id="message">
		<h4>操作成功：</h4>添加新产品
	</div>
	<?php
		}elseif($_GET['stat']=='error'&&$_GET['error']=='duplicated'){
	?>
	<div id="message_error">
		<h4>操作失败：</h4>无法添加新产品（此条形码已经存在于数据库中）
	</div>
	<?php
		}elseif($_GET['stat']=='error'&&$_GET['error']=='notExist'){
	?>
	<div id="message_error">
		<h4>操作失败：</h4>无法更改新产品（此条形码不存在于数据库）
	</div>
	<?php
		}elseif($_GET['stat']=='altered'){
	?>
	<div id="message">
		<h4>操作成功：</h4>更改产品
	</div>
		<?php
		}elseif($_GET['stat']=='error'&&$_GET['error']=='badData'){
	?>
	<div id="message_error">
		<h4>操作失败：</h4>无法添加/更改产品（提交了无效数据）
	</div>
<?php

		}
}
?>
	<h4>产品列表：</h4>
	<table class="contentTable" border="1">
			<tbody><tr class="solid">
		<td>扫描条码</td>
		<td>生产款号</td>
		<td>设计版号</td>
		<td>类型</td>
        <td>年份</td>
		<td>季节</td>
		<td>流水号</td>
		<td>面料</td>
		<td>色彩</td>
		<td>尺寸</td>
		<td>设计师</td>
		<td>原价</td>
		<td>折率</td>
		<td>现售与否</td>
		<td>产品名</td>
		<td>操作</td>
		</tr>
	
	
		<?php
	    global $itemType;
			global $itemTopSize;
			global $itemSize;
			global $itemColor;
			global $itemMaterial;
			global $itemSeason;
			global $itemYear;
			global $itemType;
			global $itemDesigner;
			global $organizationType;			
		foreach($allItems as $item){
			
		?>

		<tr>
		<td><?php echo $item->scan_code;?></td>
		<td><?php echo $item->product_code;?></td>
		<td><?php echo $item->designer_code;?></td>
		<td><?php echo $itemType[$item->type];?></td>
		<td><?php echo $itemYear[$item->year];?></td>
		<td><?php echo $itemSeason[$item->season];?></td>
		<td><?php echo $item->flow;?></td>
		<td><?php echo $itemMaterial[$item->material];?></td>
		<td><?php echo $itemColor[$item->color];?></td>
		<td><?php echo $itemSize[$item->size];?></td>
		<td><?php echo $itemDesigner[$item->designer];?></td>	
		<td><?php echo $item->price;?></td>	
		<td><?php echo $item->ratio."%";?></td>	
		<td><?php echo ($item->active==1) ? '是' : '否';?></td>	
		<td><?php echo $item->name;?></td>
		<td>
			
          
          
          
          <form action="index.php" method="GET">
          	            <input type="hidden" id='scan_code' name="scan_code" value=<?php echo $item->scan_code;?> />
          	            <input type="hidden" id='page' name="page" value='alter_item'/>

<div>
<input type="submit" value="更改">
</div>
</form>


		</td>
		</tr>

	
	<?php
		}
	?>
		</tbody></table>
<br>
<br>

	<h4>添加产品：</h4>

    <div class="form">
    	<h4>方法一，只输入14位扫描条码</h4>
        <form action="api/" method="post">
        	<input type="hidden" id='action' name="action" value="add_item" />
        	<input type="hidden" id='option' name="option" value="scan_code" />

        	<input type="hidden" id='uid' name="uid" value=<?php echo $currentUser->id;?> />
          
            <div class="element">
             <label class="form">扫描条码</label>
             <input type="text" id="scan_code" name="scan_code" class="text" maxlength="14" size="14">
            </div>
      
   <div class="element" style="clear:both;">
        <label class="form">设计师代码</label>
        
        <div class='checkbox'>
        	<?php
        	foreach($itemDesigner as $key => $value)
        	{
        		
				if($key=='O'){
        	?>
                <input type="radio" name="designer" value="<?php echo $key;?>" checked="checked">设计师：<?php echo $value;?><br>
            <?php
			    }else{
			?>
			    <input type="radio" name="designer" value="<?php echo $key;?>" >设计师：<?php echo $value;?><br>
			<?php
					
				}
            }
        	?>
     </div>

    </div>
    
    <div class="element" style="clear:both;">
        <label class="form">销售与否</label>
        
        <div class='checkbox'>

                <input type="radio" name="active" value="1" checked="checked">是<br>
     
			    <input type="radio" name="active" value="0" >否<br>
	
     </div>

    </div>
     <div class="element">
             <label class="form">产品名称</label>
             <input type="text"  name="name" class="text" maxlength="30" size="30" value="未知">
      </div>
     <div class="element">
             <label class="form">官方定价</label>
             <input type="text"  name="price" class="text" maxlength="6" size="6" value="100.0">
      </div>
      <div class="element">
             <label class="form">打折(%)</label>
             <input type="text"  name="ratio" class="text" maxlength="6" size="6" value= "100"><div>%</div>
      </div>

    <div class="element">
<input type="submit" value="递交" />
        <div class="loading"></div>
    </div>
    </form>
    </div>
        <hr>

    <div class="form">
    	<h4>方法二，10位生产款号 ＋ 两位颜色码＋两位尺码</h4>
        <form action="api/" method="post">
        	<input type="hidden" id='action' name="action" value="add_item" />
        	<input type="hidden" id='option' name="option" value="product_code" />

        	<input type="hidden" id='uid' name="uid" value=<?php echo $currentUser->id;?> />
            
            <div class="element">
             <label class="form">生产款号</label>
             <input type="text" id="product_code" name="product_code" class="text" maxlength="10" size="10" >
            </div> 
            <div class="element">
             <label class="form">颜色码</label>
             <select name="color">
             <?php
             foreach ($itemColor as $key => $value) {
             ?>
             <option value='<?php echo $key;?>'><?php echo $value;?></option>
             <?php
              }
             ?>
             </select><div class="important">详见指引</div>
            </div>
            <div class="element">
             <label class="form">尺码</label>
             
              <select name="size">
             <?php
             foreach ($itemSize as $key => $value) {
             ?>
             <option value='<?php echo $key;?>'><?php echo $value;?></option>
             <?php
              }
             ?>
             </select><div class="important">详见指引</div>
            </div>
           <div class="element" style="clear:both;">
            <label class="form">设计师代码</label>
                                                                   
            <div class='checkbox'>
        	<?php
        	foreach($itemDesigner as $key => $value)
        	{
        		
				if($key=='O'){
        	?>
                <input type="radio" name="designer" value="<?php echo $key;?>" checked="checked">设计师：<?php echo $value;?><br>
            <?php
			    }else{
			?>
			    <input type="radio" name="designer" value="<?php echo $key;?>" >设计师：<?php echo $value;?><br>
			<?php
					
				}
            }
        	?>
     </div>

    </div>
     <div class="element" style="clear:both;">
        <label class="form">销售与否</label>
        
        <div class='checkbox'>

                <input type="radio" name="active" value="1" checked="checked">是<br>
     
			    <input type="radio" name="active" value="0" >否<br>
	
     </div>

    </div>
           <div class="element">
             <label class="form">产品名称</label>
             <input type="text"  name="name" class="text" maxlength="30" size="30" value="未知">
      </div>
     <div class="element">
             <label class="form">官方定价</label>
             <input type="text"  name="price" class="text" maxlength="6" size="6" value="100.0">
      </div>
      <div class="element">
             <label class="form">打折(%)</label>
             <input type="text"  name="ratio" class="text" maxlength="6" size="6" value= "100"><div>%</div>
      </div>
 

    <div class="element">
<input type="submit" value="递交" />
        <div class="loading"></div>
    </div>
    </form>
    </div>
    <hr>
    <div class="form">
    	<h4>方法三，输入所有数据</h4>
        <form action="api/" method="post">
        	<input type="hidden" id='action' name="action" value="add_item" />
        	<input type="hidden" id='option' name="option" value="all_code" />

        	<input type="hidden" id='uid' name="uid" value=<?php echo $currentUser->id;?> />
            
        
            <div class="element">
             <label class="form">类别</label>
             <select name="type">
             <?php
             foreach ($itemType as $key => $value) {
             ?>
             <option value='<?php echo $key;?>'><?php echo $value;?></option>
             <?php
              }
             ?>
             </select>
            </div> 
     
            <div class="element">
             <label class="form">年份</label>
             <select name="year">
             <?php
             foreach ($itemYear as $key => $value) {
             ?>
             <option value='<?php echo $key;?>'><?php echo $value;?></option>
             <?php
              }
             ?>
             </select>
            </div> 
     
            <div class="element">
             <label class="form">季节</label>
             <select name="season">
             <?php
             foreach ($itemSeason as $key => $value) {
             ?>
             <option value='<?php echo $key;?>'><?php echo $value;?></option>
             <?php
              }
             ?>
             </select>
            </div> 
            
             <div class="element">
             <label class="form">流水号</label>
             <input type="text" id="flow" name="flow" class="text" maxlength="3" size="3"><div class="important">"001"至"999"按顺序取号编号必须为3位</div>
            </div> 
            
      
            
             <div class="element">
             <label class="form">面料</label>
             <select name="material">
             <?php
             foreach ($itemMaterial as $key => $value) {
             ?>
             <option value='<?php echo $key;?>'><?php echo $value;?></option>
             <?php
              }
             ?>
             </select>
            
            
            </div> 
            
            <div class="element">
             <label class="form">颜色码</label>
             <select name="color">
             <?php
             foreach ($itemColor as $key => $value) {
             ?>
             <option value='<?php echo $key;?>'><?php echo $value;?></option>
             <?php
              }
             ?>
             </select><div class="important">详见指引</div>
            </div>
            <div class="element">
             <label class="form">尺码</label>
             
              <select name="size">
             <?php
             foreach ($itemSize as $key => $value) {
             ?>
             <option value='<?php echo $key;?>'><?php echo $value;?></option>
             <?php
              }
             ?>
             </select><div class="important">详见指引</div>
            </div>
           <div class="element" style="clear:both;">
            <label class="form">设计师代码</label>
                                                                   
            <div class='checkbox'>
        	<?php
        	foreach($itemDesigner as $key => $value)
        	{
        		
				if($key=='O'){
        	?>
                <input type="radio" name="designer" value="<?php echo $key;?>" checked="checked">设计师：<?php echo $value;?><br>
            <?php
			    }else{
			?>
			    <input type="radio" name="designer" value="<?php echo $key;?>" >设计师：<?php echo $value;?><br>
			<?php
					
				}
            }
        	?>
     </div>

    </div>
    
  <div class="element" style="clear:both;">
        <label class="form">销售与否</label>
        
        <div class='checkbox'>

                <input type="radio" name="active" value="1" checked="checked">是<br>
     
			    <input type="radio" name="active" value="0" >否<br>
	
     </div>

    </div>
       <div class="element">
             <label class="form">产品名称</label>
             <input type="text"  name="name" class="text" maxlength="30" size="30" value="未知">
      </div>
     <div class="element">
             <label class="form">官方定价</label>
             <input type="text"  name="price" class="text" maxlength="6" size="6" value="100.0">
      </div>
      <div class="element">
             <label class="form">打折(%)</label>
             <input type="text"  name="ratio" class="text" maxlength="6" size="6" value= "100"><div>%</div>
      </div>

    <div class="element">
<input type="submit" value="递交" />
        <div class="loading"></div>
    </div>
    </form>
    </div>
    </div>
<div class="clear"></div>
	</div>